@@ -16,7 +16,7 @@ |
||
16 | 16 |
<%= f.check_box :remember_me, as: :boolean, label: (t 'registration.remember_me') if devise_mapping.rememberable? %> |
17 | 17 |
<!-- Change this to a button or input when using this as a form --> |
18 | 18 |
<div class="form-group" style="margin-top: 25px;"> |
19 |
- <%= f.submit t 'registration.sign_in_submit' %> |
|
19 |
+ <%= f.submit (t 'registration.sign_in_submit'), id: 'submit_login_btn' %> |
|
20 | 20 |
<%= link_to (t 'registration.sign_up'), new_user_registration_path, class: 'btn btn-link ' %> |
21 | 21 |
<%= link_to (t 'registration.forgot_password'), new_user_password_path, class: 'btn btn-link ' %> |
22 | 22 |
|
@@ -1,3 +1,5 @@ |
||
1 | 1 |
# Be sure to restart your server when you modify this file. |
2 | 2 |
|
3 |
-RailsWebsiteTemplate::Application.config.session_store :cookie_store, key: '_rails_website_template_session' |
|
3 |
+RailsWebsiteTemplate::Application.config.session_store :cookie_store, key: '_rails_website_template_session', :domain => :all |
|
4 |
+ |
|
5 |
+# RailsWebsiteTemplate::Application.config.session_store :cookie_store, key: '_rails_website_template_session', expire_after: 7.days, domain: { test: AppConfig.host_name }.fetch(Rails.env.to_sym, :all) |
@@ -1,4 +1,4 @@ |
||
1 |
-@focus |
|
1 |
+@subscription |
|
2 | 2 |
Feature: Email Subscription |
3 | 3 |
|
4 | 4 |
In order to send newsletters to customers |
@@ -46,6 +46,4 @@ Feature: Email Subscription |
||
46 | 46 |
When I click in the link "Export CVS" |
47 | 47 |
Then I should see "Jimy,San,jimysan@website.com," |
48 | 48 |
And I should see "John,Doe,john_doe@website.com" |
49 |
- |
|
50 |
- # 7. Hookup the mailchimp API and send subscriber after subscription |
|
51 | 49 |
|
@@ -1,4 +1,4 @@ |
||
1 |
-include Warden::Test::Helpers |
|
1 |
+ |
|
2 | 2 |
|
3 | 3 |
Given /^the following list of blog posts?$/ do |table| |
4 | 4 |
user = FactoryGirl.create(:user) |
@@ -25,6 +25,10 @@ Then(/^spit out the page HTML$/) do |
||
25 | 25 |
puts page.html |
26 | 26 |
end |
27 | 27 |
|
28 |
+Then /^show me the page$/ do |
|
29 |
+ save_and_open_page |
|
30 |
+end |
|
31 |
+ |
|
28 | 32 |
When /^I go to (.+)$/ do |page_name| |
29 | 33 |
path_to(page_name) |
30 | 34 |
end |
@@ -1,3 +1,5 @@ |
||
1 |
+# TESTS |
|
2 |
+ |
|
1 | 3 |
Given(/^I am logged in as user$/) do |
2 | 4 |
user_login |
3 | 5 |
end |
@@ -16,12 +18,47 @@ end |
||
16 | 18 |
|
17 | 19 |
Given(/^I am not logged in$/) do |
18 | 20 |
logout(:user) |
21 |
+# current_driver = Capybara.current_driver |
|
22 |
+# begin |
|
23 |
+# Capybara.current_driver = :rack_test |
|
24 |
+# page.driver.submit :delete, "/logout", {} |
|
25 |
+# ensure |
|
26 |
+# Capybara.current_driver = current_driver |
|
27 |
+# end |
|
19 | 28 |
end |
20 | 29 |
|
21 | 30 |
Then(/^I log out$/) do |
22 | 31 |
logout(:user) |
32 |
+# current_driver = Capybara.current_driver |
|
33 |
+# begin |
|
34 |
+# Capybara.current_driver = :rack_test |
|
35 |
+# page.driver.submit :delete, "/logout", {} |
|
36 |
+# ensure |
|
37 |
+# Capybara.current_driver = current_driver |
|
38 |
+# end |
|
39 |
+end |
|
40 |
+ |
|
41 |
+Given(/^the user "(.*?)" "(.*?)" with email "(.*?)" and password "(.*?)" exists$/) do |arg1, arg2, arg3, arg4| |
|
42 |
+ user_hash = { "first_name" => arg1, "last_name" => arg2, "email" => arg3, "password" => arg4 } |
|
43 |
+ if User.find_by_email(arg3) == nil |
|
44 |
+ user = FactoryGirl.create(:user, user_hash) |
|
45 |
+ end |
|
46 |
+ if User.last.email != arg3 |
|
47 |
+ return false |
|
48 |
+ end |
|
23 | 49 |
end |
24 | 50 |
|
51 |
+Then(/^I log in with the email "(.*?)" and password "(.*?)"$/) do |arg1, arg2| |
|
52 |
+ fill_in "user_email", :with => arg1 |
|
53 |
+ fill_in "user_password", :with => arg2 |
|
54 |
+ click_button "Submit" |
|
55 |
+ user = User.find_by_email(arg1) |
|
56 |
+ login_as user, scope: :user |
|
57 |
+ visit root_path |
|
58 |
+end |
|
59 |
+ |
|
60 |
+# METHODS |
|
61 |
+ |
|
25 | 62 |
def user_login |
26 | 63 |
if User.find_by_first_name("John") == nil |
27 | 64 |
user = FactoryGirl.create(:user) |
@@ -54,15 +54,15 @@ end |
||
54 | 54 |
# Possible values are :truncation and :transaction |
55 | 55 |
# The :transaction strategy is faster, but might give you threading problems. |
56 | 56 |
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature |
57 |
+ |
|
57 | 58 |
Cucumber::Rails::Database.javascript_strategy = :truncation |
58 | 59 |
require "#{Rails.root}/spec/factories.rb" |
59 | 60 |
|
60 | 61 |
# Make sure this require is after you require cucumber/rails/world. |
61 | 62 |
require 'email_spec' # add this line if you use spork |
62 | 63 |
require 'email_spec/cucumber' |
64 |
+require "#{Rails.root}/spec/spec_helper" |
|
63 | 65 |
|
64 | 66 |
ActionMailer::Base.delivery_method = :test |
65 | 67 |
ActionMailer::Base.perform_deliveries = true |
66 | 68 |
ActionMailer::Base.deliveries.clear |
67 |
- |
|
68 |
- |
@@ -7,6 +7,9 @@ module NavigationHelpers |
||
7 | 7 |
when/the homepage/ |
8 | 8 |
root_path |
9 | 9 |
|
10 |
+ when/the login page/ |
|
11 |
+ visit new_user_session_path |
|
12 |
+ |
|
10 | 13 |
when/the admin dashboard/ |
11 | 14 |
visit admin_dashboard_path |
12 | 15 |
|
@@ -0,0 +1,3 @@ |
||
1 |
+Warden.test_mode! |
|
2 |
+World Warden::Test::Helpers |
|
3 |
+After { Warden.test_reset! } |
@@ -0,0 +1,25 @@ |
||
1 |
+@focus |
|
2 |
+Feature: User Account |
|
3 |
+ In order to change content in the website |
|
4 |
+ As user of the system |
|
5 |
+ I want to create, update adn delete my user account |
|
6 |
+ |
|
7 |
+ Background: |
|
8 |
+ Given the website is configured |
|
9 |
+ |
|
10 |
+ Scenario: Registered user login |
|
11 |
+ Given the user "Monty" "Cantsin" with email "monty_cantsin@canada.com" and password "12345678" exists |
|
12 |
+ And I am not logged in |
|
13 |
+ When I go to the login page |
|
14 |
+ Then I should see "Sign In" |
|
15 |
+ And I log in with the email "monty_cantsin@canada.com" and password "12345678" |
|
16 |
+ Then I should see "Monty Cantsin" |
|
17 |
+ And I should see "Logout" |
|
18 |
+ |
|
19 |
+ Scenario: Registered user logout |
|
20 |
+ Given the user "Monty" "Cantsin" with email "monty_cantsin@canada.com" and password "12345678" exists |
|
21 |
+ And I am not logged in |
|
22 |
+ When I go to the login page |
|
23 |
+ And I log in with the email "monty_cantsin@canada.com" and password "12345678" |
|
24 |
+ Then I click in the link "Logout" |
|
25 |
+ And I should see "Signed out successfully" |
@@ -19,7 +19,7 @@ |
||
19 | 19 |
|
20 | 20 |
|
21 | 21 |
RSpec.configure do |config| |
22 |
- |
|
22 |
+ |
|
23 | 23 |
# rspec-expectations config goes here. You can use an alternate |
24 | 24 |
# assertion/expectation library such as wrong or the stdlib/minitest |
25 | 25 |
# assertions if you prefer. |
@@ -0,0 +1,3 @@ |
||
1 |
+RSpec.configure do |config| |
|
2 |
+ config.include Devise::TestHelpers, :type => :controller, :feature |
|
3 |
+end |